<template>
	<view>
    <!-- 车辆信  -->
    <commonWin> </commonWin>
    <view class="top tac fw">
      <text>请完善</text>
      <text class="color">基本信息</text>
    </view>
<!--		<view class="messageBar fz12">-->
<!--			<view class="disb aic">-->
<!--				<text>行业</text>-->
<!--				<view class="select disp aic" style="font-weight: 700">-->
<!--					<u&#45;&#45;input-->
<!--					    placeholder="请输入"-->
<!--						inputAlign='right'-->
<!--						border='none'-->
<!--					    v-model="car.industry"-->
<!--					></u&#45;&#45;input>-->
<!--				</view>-->
<!--			</view>-->
<!--		</view>-->
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(1)">
				<text>车辆状态</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{car.carState?car.carState:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(2)">
				<text>车辆座位</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{car.carNumber?car.carNumber:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(3)">
				<text>车辆动力</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{car.carPower?car.carPower:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(4)">
				<text>是否个人名下</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{car.isOperation?car.isOperation:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>
<!--		<view class="messageBar fz12">-->
<!--			<view class="disb aic" @click="click(5)">-->
<!--				<text>职务</text>-->
<!--				<view class="select disp aic" style="font-weight: 700">-->
<!--					<text class="color10">{{car.job?car.job:'请选择'}}</text>-->
<!--					<image src="../../static/images/preat/right.png" mode=""></image>-->
<!--				</view>-->
<!--			</view>-->
<!--		</view>-->

    <view class="messageBar fz12">
      <view class="disb aic">
        <text>全款车目前市场价（可以填个大概）（可以多辆车叠加）</text>
        <view class="select disp aic" style="font-weight: 700">
          <u-input
              type="digit"
              maxlength="12"
              placeholder="请输入"
              inputAlign='right'
              border='none'
              v-model="car.totalPayment"
          ></u-input>
          <text>元</text>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic">
        <text>抵押、按揭车剩余本金（可以填个大概）（可以多辆车叠加）</text>
        <view class="select disp aic" style="font-weight: 700">
          <u-input
              type="digit"
              maxlength="12"
              placeholder="请输入"
              inputAlign='right'
              border='none'
              v-model="car.oddCorpus"
          ></u-input>
          <text>元</text>
        </view>
      </view>
    </view>

		<u-picker :show="show" :immediateChange="true" :columns="list" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
		<view class="upBtn tac colorf" @click="toSee">提交</view>
	</view>
</template>

<script>
import {getIsCar, setIsCar, upDateIsCar} from "../../api/information.js"
import commonWin from "../../components/informtionList/commonWin.vue"
	export default {
		name:"car",
    components: {
      commonWin,
    },
		props:{
      flag:{
        type:Boolean,
        default:()=>{return false}
      },
      pid:{
        type:String,
        default:()=>{return ''}
      },
			isThis:{
				type:Number,
				default:()=>{return ''}
			},
      ui:{
        type:String,
        default:()=>{return "0"}
      },
			listId:{
				type:String,
				default:()=>{return ''}
			}
		},
		data() {
			return {
				show:false,
				select:null,
				userType:uni.getStorageSync('userInfo').userType,
				status:false,
				car:{
					userId: uni.getStorageSync('userInfo').id,
					industry:'',
					carState:'',
					carNumber:'',
					carPower:'',
					isOperation:'',
					job:'',
					totalPayment:'',
					oddCorpus:''
				},
				list:[]
			};
		},
		onReady() {
			if(this.isThis==7){
				if(this.listId){
					this.getMessage()
				}
			}
		},
		methods:{
			// 获取是否填写车辆资料
			getMessage(){
				getIsCar({id:this.listId,ui:this.ui}).then(res => {
					this.car = res.data
				})
			},
			//提交
			toSee(){
				if(this.listId){
					this.car.id = this.listId
          uni.$u.toast('资料提交中...')
					upDateIsCar(this.car).then(res => {
						if(res.code==0){
							uni.$u.toast('保存成功')
							setTimeout(()=>{
                uni.navigateBack()
							},500)
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}else{
          uni.$u.toast('资料提交中...')
					setIsCar(this.car).then(res => {
						if(res.code==0){
              if (this.flag){
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=&type=1&tableId=0`
                })
              }else {
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=${this.pid}&type=0&tableId=`+res.data
                })
              }
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}
			},
			//选择
			click(i){
				this.show = true
				this.select = i
				if(i==1){
					this.list = [['全款','抵押','按揭']]
				}
				if(i==2){
					this.list = [['2座','4座','5座','7座','9座','9座以上']]
				}
				if(i==3){
					this.list = [['油车','电车','油电混动']]
				}
				if(i==4){
					this.list = [['是','否']]
				}
				if(i==5){
					this.list = [['法人','股东（必须持股20%以上）','上班']]
				}
				if(i==6||i==7||i==8||i==9||i==10||i==11||i==12||i==13||i==14||i==15){
					this.list = [['不限','是','否']]
				}
			},
			//确认选择
			sexSelect(e){
				this.show = false
				if(this.select==1){
					this.car.carState = e.value[0]
				}
				if(this.select==2){
					this.car.carNumber = e.value[0]
				}
				if(this.select==3){
					this.car.carPower = e.value[0]
				}
				if(this.select==4){
					this.car.isOperation = e.value[0]
				}
				if(this.select==5){
					this.car.job = e.value[0]
				}
			}
		}
	}
</script>

<style lang="scss">
.top{
	line-height: 80rpx;
	background-color: #eaf3ff;
}
.messageBar{
	min-height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	margin-bottom: 10rpx;
	background-color: #fff;
	.select{
		image{
			width: 20rpx;
			height: 30rpx;
			margin-left: 10rpx;
		}
		.input{
			width: 100rpx;
		}
	}
	.btn{
		width: 150rpx;
		line-height: 60rpx;
		margin-right: 10rpx;
		border-radius: 30rpx;
		background-color: #ccc;
	}
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: #0055ff;
	margin: 40rpx auto 20rpx;
}
</style>